<?php
require_once(CORE_DIR.'userModel.php');

class authAction extends Action{
	
	function __construct() {
	}

	public function run($get, $post, $viewtype) {
		$this->view->setRenderType($viewtype);

		if(!isset($this->logger))
			$this->logger = new Logger();
		
		$uModel = new userModel();
		$user = $uModel->getActiveUser();
		
		if($user == null && !$uModel->isLoggedIn() && !$uModel->isAutoLoggedIn())
		{
			if($user!=null)
				$this->logger->addLog("cmd: ".$_GET['cmd']." session: ".session_id()." user: ".$user->getId()."|".$user->getNickName(), Logger::DEBUG_LEVEL);
			else 
				$this->logger->addLog("cmd: ".$_GET['cmd']." session: ".session_id()." user: empty", Logger::DEBUG_LEVEL);
			if(isset($_GET["usejson"]) && $_GET["usejson"]==1)
				redirect('/index.php?cmd=mustlogin&usejson=1');
			else
				redirect('/index.php?cmd=mustlogin');
		}
	}
}
?>